<template>
    <div>
        <table>
            <tr>
                <td>用户名</td>
                <td><input type="text" v-model="info.name"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" v-model="info.password"></td>
            </tr>
            <tr>
                <td colspan="2"><input type="button" value="登录" @click="add()"></td>
            </tr>
        </table>

    </div>
</template>

<script setup lang="ts">
    import {ref} from 'vue';
    import axios from 'axios';
    import { useRouter } from 'vue-router';

    const info=ref({
  "id": 0,
  "name": "",
  "password": ""
})

    const add=()=>{
    if(info.value.name==""){
        alert('用户名不能为空');
        return;
    }
    if(info.value.password==""){
        alert('密码不能为空');
        return;
    }
    axios.get("https://localhost:7108/api/Member/Login",{params:info.value}).then(res=>{
        if(res.data.id==-1){
            alert('用户名错误')
            return;
        }
        if(res.data.id==-2){
            alert('密码错误')
            return;
        }
        if(res.data.id>0){
            alert('登录成功');
        }
        else{
            alert('登录失败');
        }
    })
}







    const router=useRouter();


</script>
